/**
 * Created by lwy on 2017/8/11.
 */


var page = 1;

function doAjax(){
    $.ajax({
        url:'/crm/transferC/getAllTransferRecord',
        dataType:'json',
        data:{
            token:localStorage.getItem('crmtoken'),
            page:page,
            stateValue:$('#state').val(),
            toUserName:$('#toUserName').val(),
            code:$('#code').val(),
            userName:$('#userName').val(),
        },
        type:'post',
        success: function (data) {
            if(data.code==-1){
                window.parent.location.href="/crm/login.jsp"
            }
            if(data.code==0){
                alert(data.msg);
            }
            if(data.code==1){
                $('#record').html(data.recordsTotal);
                $('#withdraw-record').empty();
                for(var i=0;i<data.datas.length;i++){

                    $('<tr class="gradeA odd">'+
                        '<td class="sorting_1 withdrawId">'+data.datas[i].id+'</td>'+
                        '<td class=" ">'+data.datas[i].userAccount+'</td>'+
                        '<td class=" ">'+data.datas[i].toUserAccount+'</td>'+
                        '<td class="center ">'+data.datas[i].code+'</td>'+
                        '<td class="center ">'+data.datas[i].money+'</td>'+
                        '<td class="center ">'+data.datas[i].creatTime+'</td>'+
                        '<td class="sorting_1">'+data.datas[i].orderState+'</td>'+
                        '</tr>').appendTo($('#withdraw-record'));
                }



                $(".pagination").createPage({
                    totalPage:data.totalPage,
                    currPage:data.pageNow,
                    turndown:'true',
                    backFn:function(p){
                        page=p;
                        doAjax();
                    }
                });
            }
        }
    })
}

$(function(){
    doAjax()
})

//查询
$('#refer').click(function(){
    page=1;
    doAjax();
})
